package com.shanpin.shebao.model.report;

import java.math.BigDecimal;

/**
 * 财务对帐汇总对象，分自有数据对帐和支付平台帐单对帐 两种对帐共用
 * 金额的单位都是 分
 * @author 品讯科技
 *
 */
public class BillsDateTotalVO {

	/** 交易订单数，不含退款 */
	private int count = 0;
	/** 交易总金额 (未减去退款) */
	private BigDecimal total = BigDecimal.ZERO;
	/** 支付平台扣取的千分之六服务费  */
	private BigDecimal k6Total = BigDecimal.ZERO;

	/** 退款单数 */
	private int refundCount = 0;
	/** 退款总金额 取绝对值  */
	private BigDecimal refundTotal = BigDecimal.ZERO;
	/** 纯收入 （减去 refundTotal，再减去 k6Total） */
	private BigDecimal income = BigDecimal.ZERO;
	

	/** 充值金额  */
	private BigDecimal rechargeFee = BigDecimal.ZERO;
	/** 充值的服务费 */
	private BigDecimal rechargeSrvFee = BigDecimal.ZERO;

	/** 转帐退款金额  */
	private BigDecimal turnRefundFee = BigDecimal.ZERO;
	/** 提现金额  */
	private BigDecimal cashDraw = BigDecimal.ZERO;
	
	public BillsDateTotalVO () {
		
	}
	
	public static BillsDateTotalVO of(int refundCount, BigDecimal refundTotal) {
		BillsDateTotalVO vo = new BillsDateTotalVO();
		vo.refundCount = refundCount;
		vo.refundTotal = refundTotal.abs();
		return vo;
	}
	
	public void ofRefund(int refundCount, BigDecimal refundTotal) {
		this.refundCount = refundCount;
		this.refundTotal = refundTotal.abs();
	}
	
	public void of(int countV, BigDecimal totalV, BigDecimal k6) {
		this.count += countV;
		this.total = this.total.add(totalV);
		if (null == k6) {
			k6 = totalV.multiply(new BigDecimal(0.006)).setScale(2, BigDecimal.ROUND_HALF_UP);
		} else {
			k6 = k6.abs().setScale(2, BigDecimal.ROUND_HALF_UP);
		}
		this.k6Total = this.k6Total.add(k6);
		this.income = this.total.subtract(this.k6Total).subtract(this.refundTotal);
	}

	// 资金对帐单. 收入和支出
	public void ofWxFundFlow(BigDecimal rechargeFee, BigDecimal turnRefundFee ) {
		this.rechargeFee = rechargeFee;
		this.turnRefundFee = turnRefundFee;
	}
	
	public int getCount() {
		return count;
	}

	public BigDecimal getTotal() {
		return total;
	}

	public BigDecimal getK6Total() {
		return k6Total;
	}

	public int getRefundCount() {
		return refundCount;
	}

	public BigDecimal getRefundTotal() {
		return refundTotal;
	}

	public BigDecimal getIncome() {
		return income;
	}

	public BigDecimal getRechargeFee() {
		return rechargeFee;
	}

	public BigDecimal getRechargeSrvFee() {
		return rechargeSrvFee;
	}

	public BigDecimal getTurnRefundFee() {
		return turnRefundFee;
	}

	public BigDecimal getCashDraw() {
		return cashDraw;
	}
}
